<template>
  <div>
    <el-table
      :data="list"
      style="width: 100%;margin-bottom: 20px;"
      row-key="id"
      border
      :tree-props="{children: 'children'}"
    >
      <el-table-column prop="id" label="用户编号" align="center"></el-table-column>
      <el-table-column prop="username" label="用户名" align="center"></el-table-column>
      <el-table-column prop="rolename" label="所属角色" align="center"></el-table-column>

      <el-table-column label="状态" align="center">
        <template slot-scope="scope">
          <el-button type="primary" v-if="scope.row.status==1">启用</el-button>
          <el-button type="info" v-else>禁用</el-button>
        </template>
      </el-table-column>

      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="primary" @click="update(scope.row.uid)">编辑</el-button>
          <!-- <el-button type="danger" @click="del(scope.row.uid)">删除</el-button> -->
          <del-btn @del="del(scope.row.uid)">删除</del-btn>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { requserdelete } from "../../../request/api";
import { successAlert } from "../../../utils/alert";
export default {
  props: ["list"],
  data() {
    return {};
  },
  methods: {
    del(uid) {
      requserdelete({ uid: uid }).then((res) => {
        if (res.data.code == 200) {
          successAlert(res.data.msg);
          this.$emit("init");
        }
      });
    },
    //修改
    update(uid) {
      // console.log(uid);
      this.$emit("update", uid);
    },
  },
};
</script>

<style lang='less'>
@import "../../../less/index.less";
/* 修改所有图标颜色 */

// .el-button--primary {
//   background-color:@header-color;
//   border-color: @header-color;
// }
// .el-button--danger {
//   background-color: @primary;
//   border-color: @primary;
// }
</style>